<!--
  - Copyright 2011 Angel Sanadinov
  -
  - This file is part of VBox WMI.
  -
  - VBox WMI is free software: you can redistribute it and/or modify
  - it under the terms of the GNU General Public License as published by
  - the Free Software Foundation, either version 3 of the License, or
  - (at your option) any later version.
  -
  - VBox WMI is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  - GNU General Public License for more details.
  -
  - You should have received a copy of the GNU General Public License
  - along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
  -->

<%@tag import="Beans.Requests.MachineManagement.Components.SharedFolderSettings"%>
<%@tag import="Beans.Requests.MachineManagement.Components.NetworkAdapterSettings"%>
<%@tag import="org.virtualbox_3_2.MediumVariant"%>
<%@tag import="org.virtualbox_3_2.StorageControllerType"%>
<%@tag import="org.virtualbox_3_2.StorageBus"%>
<%@tag import="org.virtualbox_3_2.MachineState"%>
<%@tag import="org.virtualbox_3_2.NATProtocol"%>
<%@tag import="org.virtualbox_3_2.VRDPAuthType"%>
<%@tag import="org.virtualbox_3_2.NetworkAttachmentType"%>
<%@tag import="org.virtualbox_3_2.NetworkAdapterType"%>
<%@tag import="org.virtualbox_3_2.BIOSBootMenuMode"%>
<%@tag import="org.virtualbox_3_2.FirmwareType"%>
<%@tag import="org.virtualbox_3_2.AudioControllerType"%>
<%@tag import="org.virtualbox_3_2.AudioDriverType"%>
<%@tag import="org.virtualbox_3_2.DeviceType"%>
<%@tag import="Beans.Responses.DataRetrievalComponents.MachineDataComponent"%>
<%@tag import="Beans.Responses.DataRetrievalComponents.NetworkDataComponent"%>
<%@tag import="Beans.Responses.DataRetrievalComponents.MiscDataComponent"%>
<%@tag import="Beans.Responses.DataRetrievalResponse"%>
<%@tag import="Utilities.Constants.ResourceRequestType"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="jstlc"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="jstlfn"%>
<%@taglib uri="/WEB-INF/tlds/pagePrintingTags.tld" prefix="p"%>
<%@tag description="Prints machines data." pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>

<%-- Attributes --%>
<%@attribute name="data" required="true" description="Machine(s) data response object."
             rtexprvalue="true" type="DataRetrievalResponse<MachineDataComponent>"%>

<%@attribute name="mediumFormatsData" required="true" description="Medium formats data response object"
             rtexprvalue="true" type="DataRetrievalResponse<MiscDataComponent>" %>
<%-- End of Attributes --%>

<%-- Page Body Content --%>
<jstlc:choose>
    <jstlc:when test="${data == null}">
        Failed to retrieve medium/media data object.
    </jstlc:when>

    <jstlc:when test="${data.requestResult && data.valid}">
        <jstlc:choose>
            <jstlc:when test="<%= data.getResourceRequestType() == ResourceRequestType.SINGLE_RESOURCE %>">
                <jstlc:set var="MachineState_ABORTED" value="<%= MachineState.ABORTED %>"/>
                <jstlc:set var="MachineState_POWERED_OFF" value="<%= MachineState.POWERED_OFF %>"/>
                <form id="formModifyMachine" action="manage_machine.jsp?action=4&amp;id=${data.resource.machineData.resourceId}" method="post">
                <table id="mainMachineTable" class="mainResourceDataTable">
                    <jstlc:set var="machine" value="${data.resource}"/>
                    <tr><td>Machine ID:</td><td>${machine.machineData.resourceId}</td></tr>
                    <tr><td>Machine Name:</td><td>${machine.machineName}</td>
                        <td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('modifyMachineName');">Modify</a></td></tr>
                    <tr><td>Execution:</td><td><p:printMachineOps machine="${machine}"/></td></tr>
                    <tr><td>Machine State:</td><td>${machine.machineState}</td></tr>
                    <tr><td>Description:</td><td>${machine.machineDescription}</td>
                        <td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('modifyMachineDescription');">Modify</a></td></tr>
                    <tr><td>OS Type:</td><td>${machine.osTypeId}</td></tr>
                    <tr><td>Server ID:</td><td>${machine.machineData.serverId}</td></tr>
                    <tr><td>Owner ID:</td><td>${machine.machineData.ownerId}</td>
                        <td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('modifyMachineOwner');">Modify</a></td></tr>
                    <tr><td>Creation Date:</td><td>${machine.machineData.dateCreated}</td></tr>
                    <tr><td>Permissions:</td><td>${machine.machineData.permissions}</td>
                        <td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('modifyMachinePermissions');">Modify</a></td></tr>
                    <tr><td>Snapshots:</td><td>${machine.numberOfSnapshots}</td><td><a class="actionLink" href="snapshots.jsp?id=${machine.machineData.resourceId}">Manage</a></td></tr>

                    <tr><td><input type="submit" value="Apply Changes" ${(machine.machineState == MachineState_ABORTED || machine.machineState == MachineState_POWERED_OFF) ? "" : "disabled"}></td>
                        <td><input type="reset" value="Discard Changes"></td></tr>
                </table>
                <div id="machineOperations">
                    <jstlc:set var="linkClass" value="${(machine.machineState == MachineState_ABORTED || machine.machineState == MachineState_POWERED_OFF) ? ' actionLink' : 'unavailableModificationLink'}" />
                    <a class="${linkClass}" href="noJavaScript.jsp" onclick="return changePopupVisibility('audioSettingsTable');">Audio Settings</a><br>
                    <a class="${linkClass}" href="noJavaScript.jsp" onclick="return changePopupVisibility('biosSettingsTable');">BIOS Settings</a><br>
                    <a class="${linkClass}" href="noJavaScript.jsp" onclick="return changePopupVisibility('bootSettingsTable');">Boot Settings</a><br>
                    <a class="${linkClass}" href="noJavaScript.jsp" onclick="return changePopupVisibility('cpuSettingsTable');">CPU Settings</a><br>
                    <a class="${linkClass}" href="noJavaScript.jsp" onclick="return changePopupVisibility('ioSettingsTable');">I/O Settings</a><br>
                    <a class="${linkClass}" href="noJavaScript.jsp" onclick="return changePopupVisibility('memorySettingsTable');">Memory Settings</a><br>
                    <a class="${linkClass}" href="noJavaScript.jsp" onclick="return changePopupVisibility('vrdpSettingsTable');">VRDP Settings</a><br>
                    <a class="${linkClass}" href="noJavaScript.jsp" onclick="return changePopupVisibility('videoSettingsTable');">Video Settings</a><br>
                    <a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('networkAdaptersSettingsTable');">Network Adapters</a><br>
                    <a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('sharedFoldersSettingsTable');">Shared Folders</a><br>
                    <a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('storageSettingsTable');">Storage Settings</a><br>
                    <a class="${linkClass}" href="manage_machine.jsp?action=8&amp;id=${machine.machineData.resourceId}&amp;force"
                               onclick="return resourceRemovalVerification('${machine.machineName}', this);">Remove Machine</a>
                </div>
                <div id="modifyMachineName" class="resourceModification">
                    <input type="hidden" name="modify.machine.name.configure" disabled>
                    Machine Name: <input type="text" name="modify.machine.name" value="${machine.machineName}"><br>
                    <a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('modifyMachineName', 'modify.machine.name');">Save</a>
                </div>
                <div id="modifyMachineDescription" class="resourceModification">
                    <input type="hidden" name="modify.machine.description.configure" disabled>
                    Machine Description:<br><textarea cols="30" rows="6" name="modify.machine.description">${machine.machineDescription}</textarea><br>
                    <a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('modifyMachineDescription', 'modify.machine.description');">Save</a>
                </div>
                <div id="modifyMachinePermissions" class="resourceModification">
                    <input type="hidden" name="modify.machine.permissions.configure" disabled>
                    Machine Permissions: <input type="text" size="2" name="modify.machine.permissions" value="${machine.machineData.permissions}"><br>
                    <a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('modifyMachinePermissions', 'modify.machine.permissions');">Save</a>
                </div>
                <div id="modifyMachineOwner" class="resourceModification">
                    <input type="hidden" name="modify.machine.newOwner.configure" disabled>
                    Machine Owner: <input type="text" name="modify.machine.newOwner" size="3" value="${machine.machineData.ownerId}"><br>
                    <a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('modifyMachineOwner', 'modify.machine.newOwner');">Save</a>
                </div>

                <jstlc:set var="AudioControllerType_AC_97" value="<%= AudioControllerType.AC_97 %>"/>
                <jstlc:set var="AudioControllerType_SB_16" value="<%= AudioControllerType.SB_16 %>"/>
                <jstlc:set var="AudioDriverType_NULL" value="<%= AudioDriverType.NULL %>"/>
                <jstlc:set var="AudioDriverType_ALSA" value="<%= AudioDriverType.ALSA %>"/>
                <jstlc:set var="AudioDriverType_CORE_AUDIO" value="<%= AudioDriverType.CORE_AUDIO %>"/>
                <jstlc:set var="AudioDriverType_DIRECT_SOUND" value="<%= AudioDriverType.DIRECT_SOUND %>"/>
                <jstlc:set var="AudioDriverType_MMPM" value="<%= AudioDriverType.MMPM %>"/>
                <jstlc:set var="AudioDriverType_OSS" value="<%= AudioDriverType.OSS %>"/>
                <jstlc:set var="AudioDriverType_PULSE" value="<%= AudioDriverType.PULSE %>"/>
                <jstlc:set var="AudioDriverType_SOL_AUDIO" value="<%= AudioDriverType.SOL_AUDIO %>"/>
                <jstlc:set var="AudioDriverType_WIN_MM" value="<%= AudioDriverType.WIN_MM %>"/>
                <table id="audioSettingsTable" class="resourceDataTable">
                    <tr><td>Audio Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.audio.configure" disabled></td></tr>
                    <tr><td>Enabled:</td><td><input type="checkbox" name="modify.machine.audio.enable" ${machine.audioSettings.adapterState ? "checked" : ""}></td></tr>
                    <tr><td>Controller Type:</td>
                        <td><select name="modify.machine.audio.controllerType">
                               <option value="${AudioControllerType_AC_97}" ${machine.audioSettings.controllerType == AudioControllerType_AC_97 ? "selected" : ""}>AC'97</option>
                               <option value="${AudioControllerType_SB_16}" ${machine.audioSettings.controllerType == AudioControllerType_SB_16 ? "selected" : ""}>SoundBlaster 16</option>
                            </select></td></tr>
                    <tr><td>Driver Type:</td>
                        <td><select name="modify.machine.audio.driverType">
                               <option value="${AudioDriverType_NULL}" ${machine.audioSettings.driverType == AudioDriverType_NULL ? "selected" : ""}>none</option>
                               <option value="${AudioDriverType_ALSA}" ${machine.audioSettings.driverType == AudioDriverType_ALSA ? "selected" : ""}>ALSA (L)</option>
                               <option value="${AudioDriverType_CORE_AUDIO}" ${machine.audioSettings.driverType == AudioDriverType_CORE_AUDIO ? "selected" : ""}>CoreAudio (M)</option>
                               <option value="${AudioDriverType_DIRECT_SOUND}" ${machine.audioSettings.driverType == AudioDriverType_DIRECT_SOUND ? "selected" : ""}>DirectSound (W)</option>
                               <option value="${AudioDriverType_MMPM}" ${machine.audioSettings.driverType == AudioDriverType_MMPM ? "selected" : ""}>MMPM</option>
                               <option value="${AudioDriverType_OSS}" ${machine.audioSettings.driverType == AudioDriverType_OSS ? "selected" : ""}>OSS (L)</option>
                               <option value="${AudioDriverType_PULSE}" ${machine.audioSettings.driverType == AudioDriverType_PULSE ? "selected" : ""}>PulseAudio (L)</option>
                               <option value="${AudioDriverType_SOL_AUDIO}" ${machine.audioSettings.driverType == AudioDriverType_SOL_AUDIO ? "selected" : ""}>Solaris Audio (S)</option>
                               <option value="${AudioDriverType_WIN_MM}" ${machine.audioSettings.driverType == AudioDriverType_WIN_MM ? "selected" : ""}>Windows Multimedia (W)</option>
                            </select></td></tr>
                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('audioSettingsTable', 'modify.machine.audio');">Save</a></td></tr>
                </table>
                            
                <jstlc:set var="FirmwareType_BIOS" value="<%= FirmwareType.BIOS %>"/>
                <jstlc:set var="FirmwareType_EFI" value="<%= FirmwareType.EFI %>"/>
                <jstlc:set var="FirmwareType_EFIDUAL" value="<%= FirmwareType.EFIDUAL %>"/>
                <jstlc:set var="FirmwareType_EFI_32" value="<%= FirmwareType.EFI_32 %>"/>
                <jstlc:set var="FirmwareType_EFI_64" value="<%= FirmwareType.EFI_64 %>"/>
                <jstlc:set var="BIOSBootMenuMode_DISABLED" value="<%= BIOSBootMenuMode.DISABLED %>"/>
                <jstlc:set var="BIOSBootMenuMode_MENU_ONLY" value="<%= BIOSBootMenuMode.MENU_ONLY %>"/>
                <jstlc:set var="BIOSBootMenuMode_MESSAGE_AND_MENU" value="<%= BIOSBootMenuMode.MESSAGE_AND_MENU %>"/>
                <table id="biosSettingsTable" class="resourceDataTable">
                    <tr><td>BIOS Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.bios.configure" disabled></td></tr>
                    <tr><td>Firmware Type:</td>
                        <td><select name="modify.machine.bios.firmware">
                              <option value="${FirmwareType_BIOS}" ${machine.biosSettings.firmwareType == FirmwareType_BIOS ? "selected" : ""}>BIOS</option>
                              <option value="${FirmwareType_EFI}" ${machine.biosSettings.firmwareType == FirmwareType_EFI ? "selected" : ""}>EFI</option>
                              <option value="${FirmwareType_EFIDUAL}" ${machine.biosSettings.firmwareType == FirmwareType_EFIDUAL ? "selected" : ""}>EFI (32 bit & 64 bit)</option>
                              <option value="${FirmwareType_EFI_32}" ${machine.biosSettings.firmwareType == FirmwareType_EFI_32 ? "selected" : ""}>EFI (32 bit)</option>
                              <option value="${FirmwareType_EFI_64}" ${machine.biosSettings.firmwareType == FirmwareType_EFI_64 ? "selected" : ""}>EFI (64 bit)</option>
                            </select></td></tr>
                    <tr><td>HPET Enabled:</td><td><input type="checkbox" name="modify.machine.bios.hpetEnabled" ${machine.biosSettings.isHpetEnabled ? "checked" : ""}></td></tr>
                    <tr><td>Run RTC in UTC:</td><td><input type="checkbox" name="modify.machine.bios.RTCinUTC" ${machine.biosSettings.runRTCinUTC ? "checked" : ""}></td></tr>
                    <tr><td>Boot Menu Mode:</td>
                        <td><select name="modify.machine.bios.bootMenuMode">
                               <option value="${BIOSBootMenuMode_DISABLED}" ${machine.biosSettings.bootMenuMode == BIOSBootMenuMode_DISABLED ? "selected" : ""}>Disabled</option>
                               <option value="${BIOSBootMenuMode_MENU_ONLY}" ${machine.biosSettings.bootMenuMode == BIOSBootMenuMode_MENU_ONLY ? "selected" : ""}>Menu Only</option>
                               <option value="${BIOSBootMenuMode_MESSAGE_AND_MENU}" ${machine.biosSettings.bootMenuMode == BIOSBootMenuMode_MESSAGE_AND_MENU ? "selected" : ""}>Message and Menu</option>
                            </select></td></tr>
                    <tr><td>ACPI Enabled:</td><td><input type="checkbox" name="modify.machine.bios.acpiEnabled" ${machine.biosSettings.isACPIEnabled ? "checked" : ""}></td></tr>
                    <tr><td>IOAPIC Enabled:</td><td><input type="checkbox" name="modify.machine.bios.ioapicEnabled" ${machine.biosSettings.isIOAPICEnabled ? "checked" : ""}></td></tr>
                    <tr><td>Host Time Offset:</td><td><input type="text" size="2" name="modify.machine.bios.timeOffset" value="${machine.biosSettings.hostTimeOffset}"> ms</td></tr>
                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('biosSettingsTable', 'modify.machine.bios');">Save</a></td></tr>
                </table>

                <jstlc:set var="DeviceType_NULL" value="<%= DeviceType.NULL %>"/>
                <jstlc:set var="DeviceType_DVD" value="<%= DeviceType.DVD %>"/>
                <jstlc:set var="DeviceType_FLOPPY" value="<%= DeviceType.FLOPPY %>"/>
                <jstlc:set var="DeviceType_HARD_DISK" value="<%= DeviceType.HARD_DISK %>"/>
                <jstlc:set var="DeviceType_NETWORK" value="<%= DeviceType.NETWORK %>"/>
                <jstlc:set var="DeviceType_SHARED_FOLDER" value="<%= DeviceType.SHARED_FOLDER %>"/>
                <jstlc:set var="DeviceType_USB" value="<%= DeviceType.USB %>"/>
                <table id="bootSettingsTable" class="resourceDataTable">
                    <tr><td>Boot Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.boot.configure" disabled></td></tr>
                    <tr><td>Boot Slot</td><td>Device Type</td></tr>
                    <jstlc:forEach varStatus="loop" var="slotDevice" items="${machine.bootSettings.devices}">
                        <tr><td>${loop.index}</td>
                            <td><select name="modify.machine.boot.slot${loop.index}">
                                  <option value="${DeviceType_NULL}" ${slotDevice == DeviceType_NULL ? "selected" : ""}>none</option>
                                  <option value="${DeviceType_DVD}" ${slotDevice == DeviceType_DVD ? "selected" : ""}>DVD</option>
                                  <option value="${DeviceType_FLOPPY}" ${slotDevice == DeviceType_FLOPPY ? "selected" : ""}>Floppy</option>
                                  <option value="${DeviceType_HARD_DISK}" ${slotDevice == DeviceType_HARD_DISK ? "selected" : ""}>Hard Disk</option>
                                  <option value="${DeviceType_NETWORK}" ${slotDevice == DeviceType_NETWORK ? "selected" : ""}>Network</option>
                                  <option value="${DeviceType_SHARED_FOLDER}" ${slotDevice == DeviceType_SHARED_FOLDER ? "selected" : ""}>Shared Folder</option>
                                  <option value="${DeviceType_USB}" ${slotDevice == DeviceType_USB ? "selected" : ""}>USB</option>
                                </select></td></tr>
                    </jstlc:forEach>
                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('bootSettingsTable', 'modify.machine.boot');">Save</a></td></tr>
                </table>
              
                <table id="cpuSettingsTable" class="resourceDataTable">
                    <tr><td>CPU Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.cpu.configure" disabled></td></tr>
                    <tr><td>Hot Plugging Enabled:</td>
                        <td><input type="checkbox" name="modify.machine.cpu.hotPluggingEnabled" ${machine.cpuSettings.isCPUHotPlugEnabled ? "checked" : ""}></td></tr>
                    <tr><td>Available CPUs:</td><td><input type="text" size="2" name="modify.machine.cpu.count" value="${machine.cpuSettings.CPUCount}"></td></tr>
                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('cpuSettingsTable', 'modify.machine.cpu');">Save</a></td></tr>
                </table>

                <table id="ioSettingsTable" class="resourceDataTable">
                    <tr><td>I/O Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.io.configure" disabled></td></tr>
                    <tr><td>Cache Enabled:</td><td><input type="checkbox" name="modify.machine.io.cacheEnabled" ${machine.ioSettings.cacheStatus ? "checked" : ""}></td></tr>
                    <tr><td>Cache Size:</td><td><input type="text" size="3" name="modify.machine.io.cacheSize" value="${machine.ioSettings.cacheSize}"> MB</td></tr>
                    <tr><td>Cache Max Bandwidth:</td>
                        <td><input type="text" size="3" name="modify.machine.io.cacheMaxBandwidth" value="${machine.ioSettings.cacheMaxBandwidth}"> MB/s</td></tr>
                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('ioSettingsTable', 'modify.machine.io');">Save</a></td></tr>
                </table>

                <table id="memorySettingsTable" class="resourceDataTable">
                    <tr><td>Memory Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.memory.configure" disabled></td></tr>
                    <tr><td>RAM Size:</td><td><input type="text" size="3" name="modify.machine.memory.ramSize" value="${machine.memorySettings.ramSize}"> MB</td></tr>
                    <tr><td>RAM Balloon Size:</td>
                        <td><input type="text" size="3" name="modify.machine.memory.ramBalloonSize" value="${machine.memorySettings.ramBalloonSize}"> MB</td></tr>
                    <tr><td>Page Fusion Enabled:</td>
                        <td><input type="checkbox" name="modify.machine.memory.pageFusionEnabled" ${machine.memorySettings.isPageFusionEnabled ? "checked" : ""}></td></tr>
                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('memorySettingsTable', 'modify.machine.memory');">Save</a></td></tr>
                </table>

                <jstlc:if test="${machine.machineState == MachineState_ABORTED || machine.machineState == MachineState_POWERED_OFF}">
                <jstlc:set var="NetworkAdapterType_NULL" value="<%= NetworkAdapterType.NULL %>"/>
                <jstlc:set var="NetworkAdapterType_AM_79_C_970_A" value="<%= NetworkAdapterType.AM_79_C_970_A %>"/>
                <jstlc:set var="NetworkAdapterType_AM_79_C_973" value="<%= NetworkAdapterType.AM_79_C_973 %>"/>
                <jstlc:set var="NetworkAdapterType_I_82540_EM" value="<%= NetworkAdapterType.I_82540_EM %>"/>
                <jstlc:set var="NetworkAdapterType_I_82543_GC" value="<%= NetworkAdapterType.I_82543_GC %>"/>
                <jstlc:set var="NetworkAdapterType_I_82545_EM" value="<%= NetworkAdapterType.I_82545_EM %>"/>
                <jstlc:set var="NetworkAdapterType_VIRTIO" value="<%= NetworkAdapterType.VIRTIO %>"/>
                <jstlc:set var="NetworkAttachmentType_NULL" value="<%= NetworkAttachmentType.NULL %>"/>
                <jstlc:set var="NetworkAttachmentType_BRIDGED" value="<%= NetworkAttachmentType.BRIDGED %>"/>
                <jstlc:set var="NetworkAttachmentType_HOST_ONLY" value="<%= NetworkAttachmentType.HOST_ONLY %>"/>
                <jstlc:set var="NetworkAttachmentType_INTERNAL" value="<%= NetworkAttachmentType.INTERNAL %>"/>
                <jstlc:set var="NetworkAttachmentType_NAT" value="<%= NetworkAttachmentType.NAT %>"/>
                <jstlc:set var="NetworkAttachmentType_VDE" value="<%= NetworkAttachmentType.VDE %>"/>
                <table id="networkAdaptersSettingsTable" class="resourceDataTable">
                    <tr><td>Network Adapters Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.networks.configure" disabled></td></tr>
                    <jstlc:forEach varStatus="loop" var="adapter" items="${machine.networksSettings}">
                        <tr><td>Adapter #${loop.index}:</td>
                            <td>${adapter.adapterState ? "Enabled" : "Disabled"}</td>
                            <td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('modifyMachineNetworkAdapter${loop.index}', true);">View</a></td>
                            <td>
                                <table id="modifyMachineNetworkAdapter${loop.index}" class="resourceModification">
                                    <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.configure" disabled></td></tr>
                                    <tr><td>Enabled:</td><td><input type="checkbox" name="modify.machine.adapter${loop.index}.enabled" ${adapter.adapterState ? "checked" : ""}></td></tr>
                                    <tr><td>Adapter Type:</td>
                                        <td><select name="modify.machine.adapter${loop.index}.adapterType">
                                              <option value="${NetworkAdapterType_NULL}" ${adapter.adapterType == NetworkAdapterType_NULL ? "selected" : ""}>none</option>
                                              <option value="${NetworkAdapterType_AM_79_C_970_A}" ${adapter.adapterType == NetworkAdapterType_AM_79_C_970_A ? "selected" : ""}>PCnet-PCI II (Am79C970A)</option>
                                              <option value="${NetworkAdapterType_AM_79_C_973}" ${adapter.adapterType == NetworkAdapterType_AM_79_C_973 ? "selected" : ""}>PCnet-FAST III (Am79C973)</option>
                                              <option value="${NetworkAdapterType_I_82540_EM}" ${adapter.adapterType == NetworkAdapterType_I_82540_EM ? "selected" : ""}>Intel PRO/1000 MT Desktop (82540EM)</option>
                                              <option value="${NetworkAdapterType_I_82543_GC}" ${adapter.adapterType == NetworkAdapterType_I_82543_GC ? "selected" : ""}>Intel PRO/1000 T Server (82543GC)</option>
                                              <option value="${NetworkAdapterType_I_82545_EM}" ${adapter.adapterType == NetworkAdapterType_I_82545_EM ? "selected" : ""}>Intel PRO/1000 MT Server (82545EM)</option>
                                              <option value="${NetworkAdapterType_VIRTIO}" ${adapter.adapterType == NetworkAdapterType_VIRTIO ? "selected" : ""}>Paravirtualized Network (virtio-net)</option>
                                            </select></td></tr>
                                    <tr><td>Network Type:</td>
                                        <td><select name="modify.machine.adapter${loop.index}.attachmentType" onchange="buildNetworkSelectionOperations(this, 'modify.machine.adapter${loop.index}.');">
                                              <option value="${NetworkAttachmentType_NULL}" ${adapter.attachmentType == NetworkAttachmentType_NULL ? "selected" : ""}>none</option>
                                              <option value="${NetworkAttachmentType_BRIDGED}" ${adapter.attachmentType == NetworkAttachmentType_BRIDGED ? "selected" : ""}>Bridged</option>
                                              <option value="${NetworkAttachmentType_HOST_ONLY}" ${adapter.attachmentType == NetworkAttachmentType_HOST_ONLY ? "selected" : ""}>Host-Only</option>
                                              <option value="${NetworkAttachmentType_INTERNAL}" ${adapter.attachmentType == NetworkAttachmentType_INTERNAL ? "selected" : ""}>Internal</option>
                                              <option value="${NetworkAttachmentType_NAT}" ${adapter.attachmentType == NetworkAttachmentType_NAT ? "selected" : ""}>NAT</option>
                                              <option value="${NetworkAttachmentType_VDE}" ${adapter.attachmentType == NetworkAttachmentType_VDE ? "selected" : ""}>VDE</option>
                                            </select></td><td></td></tr>
                                    <tr><td>MAC Address:</td>
                                        <td><input type="text" size="12" name="modify.machine.adapter${loop.index}.MAC" value="${adapter.MACAddress}"></td></tr>
                                    <tr><td>Network Name:</td>
                                        <td><input type="text" id="modify.machine.adapter${loop.index}.networkNameExternal" size="36" name="modify.machine.adapter${loop.index}.networkName" value="${adapter.attachmentType == NetworkAttachmentType_INTERNAL ? adapter.externalNetworkName : adapter.attachedNetworkName}" ${adapter.attachmentType == NetworkAttachmentType_INTERNAL ? "disabled" : ""}>
                                            <input type="hidden" id="modify.machine.adapter${loop.index}.networkNameInternal" name="modify.machine.adapter${loop.index}.networkName" value="${adapter.attachedNetworkName}" ${adapter.attachmentType == NetworkAttachmentType_INTERNAL ? "" : "disabled"}></td></tr>
                                    <tr><td>Line Speed:</td>
                                        <td><input type="text" size="6" name="modify.machine.adapter${loop.index}.lineSpeed" value="${adapter.lineSpeed}"></td></tr>
                                    <tr><td>Cable Connected:</td>
                                        <td><input type="checkbox" name="modify.machine.adapter${loop.index}.cable" ${adapter.isCableConnected ? "checked" : ""}></td></tr>
                                    <tr><td>Boot Priority:</td>
                                        <td><input type="text" size="1" name="modify.machine.adapter${loop.index}.bootPriority" value="${adapter.bootPriority}"></td></tr>
                                    <jstlc:if test="${adapter.natEngineSetup != null}">
                                        <tr><td>NAT Engine:</td><td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('natEngineSettingsTable${loop.index}', true);">View</a></td></tr>
                                        <tr><td>
                                        <table id="natEngineSettingsTable${loop.index}" class="resourceModification">
                                            <tr><td>NAT&nbsp;Engine&nbsp;Settings:</td></tr>
                                            <tr><td>Port&nbsp;Forwarding&nbsp;Rules:</td><td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('natEngineForwardingRulesTable${loop.index}', true);">View</a></td></tr>
                                            <tr><td>Main&nbsp;NAT&nbsp;Configuration:</td><td><input id="modify.machine.adapter${loop.index}.natEngine.mainConfig.button" type="submit" value="Modify" onclick="return changeNATConfiguration('1', 'modify.machine.adapter${loop.index}.natEngine.mainConfig', true);"></td></tr>
                                            <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.configure" disabled></td></tr>
                                            <tr><td>MTU:</td><td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.mtu" value="${adapter.natEngineSetup.MTU}" disabled></td></tr>
                                            <tr><td>Socket&nbsp;Buffer&nbsp;Capacity&nbsp;(Send):</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.socketSend" value="${adapter.natEngineSetup.socketSendBufferCapacity}" disabled> bytes</td></tr>
                                            <tr><td>Socket&nbsp;Buffer&nbsp;Capacity&nbsp;(Receive):</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.socketReceive" value="${adapter.natEngineSetup.socketReceiveBufferCapacity}" disabled> bytes</td></tr>
                                            <tr><td>Initial&nbsp;TCP&nbsp;Window&nbsp;Size:&nbsp;(Send):</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.initialSend" value="${adapter.natEngineSetup.initialTCPWindowSendingSize}" disabled> bytes</td></tr>
                                            <tr><td>Initial&nbsp;TCP&nbsp;Window&nbsp;Size:&nbsp;(Receive):</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.initialReceive" value="${adapter.natEngineSetup.initialTCPWindowReceivingSize}" disabled> bytes</td></tr>
                                            <tr><td>NAT&nbsp;Network&nbsp;Name:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.networkName" value="${adapter.natEngineSetup.networkName}" disabled></td></tr>
                                            <tr><td>Host&nbsp;Interface&nbsp;IP:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.hostIp" value="${adapter.natEngineSetup.hostIP}" disabled></td></tr>
                                            <tr><td>TFTP&nbsp;Configuration:</td><td><input id="modify.machine.adapter${loop.index}.natEngine.tftpConfig.button" type="submit" value="Modify" onclick="return changeNATConfiguration('2', 'modify.machine.adapter${loop.index}.natEngine.tftpConfig', true);"></td></tr>
                                            <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.tftpConfig.configure" disabled></td></tr>
                                            <tr><td>TFTP&nbsp;Prefix:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.tftpConfig.prefix" value="${adapter.natEngineSetup.tftpPrefix}" disabled></td></tr>
                                            <tr><td>TFTP&nbsp;Boot&nbsp;File:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.tftpConfig.bootFile" value="${adapter.natEngineSetup.tftpBootFile}" disabled></td></tr>
                                            <tr><td>TFTP&nbsp;Next&nbsp;Server:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.tftpConfig.nextServer" value="${adapter.natEngineSetup.tftpNextServer}" disabled></td></tr>
                                            <tr><td>DNS&nbsp;Configuration:</td><td><input id="modify.machine.adapter${loop.index}.natEngine.dnsConfig.button" type="submit" value="Modify" onclick="return changeNATConfiguration('3', 'modify.machine.adapter${loop.index}.natEngine.dnsConfig', true);"></td></tr>
                                            <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.dnsConfig.configure" disabled></td></tr>
                                            <tr><td>DNS&nbsp;Pass&nbsp;Host&nbsp;Domain:</td>
                                                <td><input type="checkbox" name="modify.machine.adapter${loop.index}.natEngine.dnsConfig.passHostDomain" ${adapter.natEngineSetup.dnsPassHostDomain ? "checked" : ""} disabled></td></tr>
                                            <tr><td>DNS&nbsp;Proxy:</td>
                                                <td><input type="checkbox" name="modify.machine.adapter${loop.index}.natEngine.dnsConfig.dnsProxy" ${adapter.natEngineSetup.dnsProxy ? "checked" : ""} disabled></td></tr>
                                            <tr><td>DNS&nbsp;Use&nbsp;Host&nbsp;Resolver:</td>
                                                <td><input type="checkbox" name="modify.machine.adapter${loop.index}.natEngine.dnsConfig.useHostResolver" ${adapter.natEngineSetup.dnsUseHostResolver ? "checked" : ""} disabled></td></tr>

                                            <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.aliasMode.configure" disabled></td></tr>
                                            <tr><td>Alias&nbsp;Mode:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.aliasMode" value="${adapter.natEngineSetup.aliasMode}" disabled>
                                                    <input id="modify.machine.adapter${loop.index}.natEngine.aliasMode.button" type="submit" value="Modify" onclick="return changeNATConfiguration('4', 'modify.machine.adapter${loop.index}.natEngine.aliasMode', true);"></td></tr>
                                            <tr><td><table id="natEngineForwardingRulesTable${loop.index}" class="resourceDataTable">
                                                <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.numberOfRules" value="${jstlfn:length(adapter.natEngineSetup.newForwardingRules)}"></td></tr>
                                                <tr><td><input type="hidden" id="modify.machine.adapter${loop.index}.natEngine.numberOfNewRules" name="modify.machine.adapter${loop.index}.natEngine.numberOfNewRules" value="0"></td></tr>
                                                <tr><td>Rule Name</td><td>Protocol</td><td>Host IP</td><td>Host Port</td><td>Guest IP</td><td>Guest Port</td><td>Remove?</td></tr>
                                                <jstlc:forEach varStatus="ruleLoop" var="rule" items="${adapter.natEngineSetup.newForwardingRules}">
                                                    <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.rule${ruleLoop.index}.name" value="${rule.name}"></td></tr>
                                                    <tr><td>${rule.name}</td><td>${rule.protocol}</td><td>${rule.hostIP}</td><td>${rule.hostPort}</td>
                                                        <td>${rule.guestIP}</td><td>${rule.guestPort}</td>
                                                        <td><input type="checkbox" name="modify.machine.adapter${loop.index}.natEngine.rule${ruleLoop.index}.remove"></td></tr>
                                                </jstlc:forEach>
                                                <tr id="forwardingRuleTemplateRow" class="templateElement"><td><input type="text" name=""></td><td><select  name="">
                                                            <option value="<%= NATProtocol.TCP %>">TCP</option>
                                                            <option value="<%= NATProtocol.UDP %>">UDP</option>
                                                        </select></td><td><input type="text" name=""></td><td><input type="text" size="5" name=""></td><td><input type="text" name=""></td><td><input type="text" size="5" name=""></td><td></td></tr>
                                                <tr><td><a class="actionLink" href="noJavaScript.jsp" onclick="return addPortForwardingRuleForm('natEngineForwardingRulesTable${loop.index}', 'modify.machine.adapter${loop.index}.natEngine')">Add New Rule</a></td>
                                                    <td><a class="saveButtons" href="noJavaScript.jsp" onclick="return changePopupVisibility('natEngineForwardingRulesTable${loop.index}', 'true');">Done</a></td></tr></table>
                                                </td></tr>
                                            <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return changePopupVisibility('natEngineSettingsTable${loop.index}', 'true');">Done</a></td></tr>
                                        </table>
                                        </td></tr>
                                    </jstlc:if>
                                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('modifyMachineNetworkAdapter${loop.index}', 'modify.machine.adapter${loop.index}', true);">Save</a></td></tr>
                                </table></td></tr>
                    </jstlc:forEach>
                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('networkAdaptersSettingsTable', 'modify.machine.networks');">Save</a></td></tr>
                </table>
                </jstlc:if>

                <jstlc:set var="VRDPAuthType_NULL" value="<%= VRDPAuthType.NULL %>"/>
                <jstlc:set var="VRDPAuthType_EXTERNAL" value="<%= VRDPAuthType.EXTERNAL %>"/>
                <jstlc:set var="VRDPAuthType_GUEST" value="<%= VRDPAuthType.GUEST %>"/>
                <table id="vrdpSettingsTable" class="resourceDataTable">
                    <tr><td>VRDP Server Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.vrdp.configure" disabled></td></tr>
                    <tr><td>Server State:</td><td><input type="checkbox" name="modify.machine.vrdp.serverEnabled" ${machine.vrdpSettings.serverState ? "checked" : ""}></td></tr>
                    <tr><td>Listening Port(s):</td><td>${machine.vrdpSettings.serverPorts}</td></tr>
                    <tr><td>Listening Address:</td><td><input type="text" name="modify.machine.vrdp.serverAddress" value="${machine.vrdpSettings.serverAddress}"></td></tr>
                    <tr><td>Authentication Type:</td>
                        <td><select name="modify.machine.vrdp.authType">
                              <option value="${VRDPAuthType_NULL}" ${machine.vrdpSettings.authenticationType == VRDPAuthType_NULL ? "selected" : ""}>none</option>
                              <option value="${VRDPAuthType_EXTERNAL}" ${machine.vrdpSettings.authenticationType == VRDPAuthType_EXTERNAL ? "selected" : ""}>External</option>
                              <option value="${VRDPAuthType_GUEST}" ${machine.vrdpSettings.authenticationType == VRDPAuthType_GUEST ? "selected" : ""}>Guest</option>
                            </select></td></tr>
                    <tr><td>Authentication Timeout:</td>
                        <td><input type="text" size="3" name="modify.machine.vrdp.timeout" value="${machine.vrdpSettings.authenticationTimeout}"> ms</td></tr>
                    <tr><td>Multiple Connections Allowed:</td>
                        <td><input type="checkbox" name="modify.machine.vrdp.allowMultipleConnections" ${machine.vrdpSettings.allowMultipleConnections ? "checked" : ""}></td></tr>
                    <tr><td>Reuse Single Connection:</td>
                        <td><input type="checkbox" name="modify.machine.vrdp.reuseSingleConnection" ${machine.vrdpSettings.reuseSingleConnection ? "checked" : ""}></td></tr>
                    <tr><td>RDP Video Channel State:</td>
                        <td><input type="checkbox" name="modify.machine.vrdp.videoChannelEnabled" ${machine.vrdpSettings.rdpVideoChannelState ? "checked" : ""}></td></tr>
                    <tr><td>RDP Video Channel Quality:</td>
                        <td><input type="text" size="2" name="modify.machine.vrdp.videoChannelQuality" value="${machine.vrdpSettings.videoChannelQuality}"> %</td></tr>
                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('vrdpSettingsTable', 'modify.machine.vrdp');">Save</a></td></tr>
                </table>

                <table id="videoSettingsTable" class="resourceDataTable">
                    <tr><td>Video Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.video.configure" disabled></td></tr>
                    <tr><td>VRAM Size:</td><td><input type="text" size="3" name="modify.machine.video.vramSize" value="${machine.videoSettings.vramSize}"> MB</td></tr>
                    <tr><td>3D Acceleration Enabled:</td>
                        <td><input type="checkbox" name="modify.machine.video.3DEnabled" ${machine.videoSettings.is3DAccelerationEnabled ? "checked" : ""}></td></tr>
                    <tr><td>2D Acceleration Enabled:</td>
                        <td><input type="checkbox" name="modify.machine.video.2DEnabled" ${machine.videoSettings.is2DAccelerationEnabled ? "checked" : ""}></td></tr>
                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('videoSettingsTable', 'modify.machine.video');">Save</a></td></tr>
                </table>
                </form>

                <form id="formModifyMachineLiveSF" action="manage_machine.jsp?action=5&amp;id=${data.resource.machineData.resourceId}" method="post">
                <table id="sharedFoldersSettingsTable" class="resourceDataTable">
                    <tr><td>Shared Folders Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.folders.configure"></td></tr>
                    <tr><td><input type="hidden" name="modify.machine.folders.number" value="${jstlfn:length(machine.sharedFoldersSettings)}"></td></tr>
                    <tr><td><input type="hidden" id="modify.machine.folders.newNumber" name="modify.machine.folders.newNumber" value="0"></td></tr>
                    <tr><td>Name</td><td>Host&nbsp;Path</td><td>R&nbsp;+&nbsp;W</td><td>Accessible</td><td>Last&nbsp;Access&nbsp;Error</td><td>Remove</td></tr>
                    <jstlc:forEach varStatus="loop" var="folder" items="${machine.sharedFoldersSettings}">
                        <tr><td><input type="hidden" name="modify.machine.folders.folder${loop.index}.name" value="${folder.name}"></td></tr>
                        <tr><td>${folder.name}</td><td>${folder.hostPath}</td><td>${folder.isWritable ? "Yes" : "Read Only"}</td>
                            <td>${folder.isAccessible ? "Yes" : "No"}</td><td>${folder.lastAccessError}</td>
                            <td><input type="checkbox" name="modify.machine.folders.folder${loop.index}.remove"></td></tr>
                    </jstlc:forEach>
                    <tr id="sharedFolderTemplateRow" class="templateElement"><td><input type="text" name=""></td><td><input type="text" name=""></td><td><input type="checkbox" name=""></td><td></td></tr>
                    <tr><td><a class="actionLink" href="noJavaScript.jsp" onclick="return addSharedFolderForm('sharedFoldersSettingsTable', 'modify.machine.folders');">Add New Folder</a></td>
                        <td><input type="submit" value="Update"></td></tr></table>
                </form>
                    
                <jstlc:if test="${machine.machineState != MachineState_ABORTED && machine.machineState != MachineState_POWERED_OFF}">
                <form id="formModifyMachineLiveNet" action="manage_machine.jsp?action=5&amp;id=${data.resource.machineData.resourceId}" method="post">
                <jstlc:set var="NetworkAttachmentType_NULL" value="<%= NetworkAttachmentType.NULL %>"/>
                <jstlc:set var="NetworkAttachmentType_BRIDGED" value="<%= NetworkAttachmentType.BRIDGED %>"/>
                <jstlc:set var="NetworkAttachmentType_HOST_ONLY" value="<%= NetworkAttachmentType.HOST_ONLY %>"/>
                <jstlc:set var="NetworkAttachmentType_INTERNAL" value="<%= NetworkAttachmentType.INTERNAL %>"/>
                <jstlc:set var="NetworkAttachmentType_NAT" value="<%= NetworkAttachmentType.NAT %>"/>
                <jstlc:set var="NetworkAttachmentType_VDE" value="<%= NetworkAttachmentType.VDE %>"/>
                <table id="networkAdaptersSettingsTable" class="resourceDataTable">
                    <tr><td>Network Adapters Settings:</td></tr>
                    <tr><td><input type="hidden" name="modify.machine.networks.configure"></td></tr>
                    <jstlc:forEach varStatus="loop" var="adapter" items="${machine.networksSettings}">
                        <tr><td>Adapter #${loop.index}:</td>
                            <td>${adapter.adapterState ? "Enabled" : "Disabled"}</td>
                            <td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('modifyMachineNetworkAdapter${loop.index}', true);">View</a></td>
                            <td>
                                <table id="modifyMachineNetworkAdapter${loop.index}" class="resourceModification">
                                    <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.configure" disabled></td></tr>
                                    <tr><td>Enabled:</td><td>${adapter.adapterState ? "Yes" : "No"}</td></tr>
                                    <tr><td>Adapter Type:</td><td>${adapter.adapterType}</td></tr>
                                    <tr><td>Network Type:</td>
                                        <td><select name="modify.machine.adapter${loop.index}.attachmentType" onchange="buildNetworkSelectionOperations(this, 'modify.machine.adapter${loop.index}.');">
                                              <option value="${NetworkAttachmentType_NULL}" ${adapter.attachmentType == NetworkAttachmentType_NULL ? "selected" : ""}>none</option>
                                              <option value="${NetworkAttachmentType_BRIDGED}" ${adapter.attachmentType == NetworkAttachmentType_BRIDGED ? "selected" : ""}>Bridged</option>
                                              <option value="${NetworkAttachmentType_HOST_ONLY}" ${adapter.attachmentType == NetworkAttachmentType_HOST_ONLY ? "selected" : ""}>Host-Only</option>
                                              <option value="${NetworkAttachmentType_INTERNAL}" ${adapter.attachmentType == NetworkAttachmentType_INTERNAL ? "selected" : ""}>Internal</option>
                                              <option value="${NetworkAttachmentType_NAT}" ${adapter.attachmentType == NetworkAttachmentType_NAT ? "selected" : ""}>NAT</option>
                                              <option value="${NetworkAttachmentType_VDE}" ${adapter.attachmentType == NetworkAttachmentType_VDE ? "selected" : ""}>VDE</option>
                                            </select></td></tr>
                                    <tr><td>MAC Address:</td><td>${adapter.MACAddress}</td></tr>
                                    <tr><td>Network Name:</td>
                                        <td><input type="text" id="modify.machine.adapter${loop.index}.networkNameExternal" size="36" name="modify.machine.adapter${loop.index}.networkName" value="${adapter.attachedNetworkName}">
                                            <input type="hidden" id="modify.machine.adapter${loop.index}.networkNameInternal" name="modify.machine.adapter${loop.index}.networkName" disabled></td><td></td></tr>
                                    <tr><td>Line Speed:</td>
                                        <td><input type="text" size="6" name="modify.machine.adapter${loop.index}.lineSpeed" value="${adapter.lineSpeed}"></td></tr>
                                    <tr><td>Cable Connected:</td>
                                        <td><input type="checkbox" name="modify.machine.adapter${loop.index}.cable" ${adapter.isCableConnected ? "checked" : ""}></td></tr>
                                    <tr><td>Boot Priority:</td><td>${adapter.bootPriority}</td></tr>
                                    <jstlc:if test="${adapter.natEngineSetup != null}">
                                        <tr><td>NAT Engine:</td><td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('natEngineSettingsTable${loop.index}', true);">View</a></td></tr>
                                        <tr><td>
                                        <table id="natEngineSettingsTable${loop.index}" class="resourceModification">
                                            <tr><td>NAT Engine Settings:</td></tr>
                                            <tr><td>Port&nbsp;Forwarding&nbsp;Rules:</td><td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('natEngineForwardingRulesTable${loop.index}', true);">View</a></td></tr>
                                            <tr><td>Main&nbsp;NAT&nbsp;Configuration:</td><td><input id="modify.machine.adapter${loop.index}.natEngine.mainConfig.button" type="submit" value="Modify" onclick="return changeNATConfiguration('1', 'modify.machine.adapter${loop.index}.natEngine.mainConfig', true);"></td></tr>
                                            <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.configure" disabled></td></tr>
                                            <tr><td>MTU:</td><td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.mtu" value="${adapter.natEngineSetup.MTU}" disabled></td></tr>
                                            <tr><td>Socket&nbsp;Buffer&nbsp;Capacity&nbsp;(Send):</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.socketSend" value="${adapter.natEngineSetup.socketSendBufferCapacity}" disabled> bytes</td></tr>
                                            <tr><td>Socket&nbsp;Buffer&nbsp;Capacity&nbsp;(Receive):</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.socketReceive" value="${adapter.natEngineSetup.socketReceiveBufferCapacity}" disabled> bytes</td></tr>
                                            <tr><td>Initial&nbsp;TCP&nbsp;Window&nbsp;Size:&nbsp;(Send):</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.initialSend" value="${adapter.natEngineSetup.initialTCPWindowSendingSize}" disabled> bytes</td></tr>
                                            <tr><td>Initial&nbsp;TCP&nbsp;Window&nbsp;Size:&nbsp;(Receive):</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.initialReceive" value="${adapter.natEngineSetup.initialTCPWindowReceivingSize}" disabled> bytes</td></tr>
                                            <tr><td>NAT&nbsp;Network&nbsp;IP:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.networkName" value="${adapter.natEngineSetup.networkName}" disabled></td></tr>
                                            <tr><td>Host&nbsp;Interface&nbsp;IP:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.mainConfig.hostIp" value="${adapter.natEngineSetup.hostIP}" disabled></td></tr>
                                            <tr><td>TFTP&nbsp;Configuration:</td><td><input id="modify.machine.adapter${loop.index}.natEngine.tftpConfig.button" type="submit" value="Modify" onclick="return changeNATConfiguration('2', 'modify.machine.adapter${loop.index}.natEngine.tftpConfig', true);"></td></tr>
                                            <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.tftpConfig.configure" disabled></td></tr>
                                            <tr><td>TFTP&nbsp;Prefix:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.tftpConfig.prefix" value="${adapter.natEngineSetup.tftpPrefix}" disabled></td></tr>
                                            <tr><td>TFTP&nbsp;Boot&nbsp;File:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.tftpConfig.bootFile" value="${adapter.natEngineSetup.tftpBootFile}" disabled></td></tr>
                                            <tr><td>TFTP&nbsp;Next&nbsp;Server:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.tftpConfig.nextServer" value="${adapter.natEngineSetup.tftpNextServer}" disabled></td></tr>
                                            <tr><td>DNS&nbsp;Configuration:</td><td><input id="modify.machine.adapter${loop.index}.natEngine.dnsConfig.button" type="submit" value="Modify" onclick="return changeNATConfiguration('3', 'modify.machine.adapter${loop.index}.natEngine.dnsConfig', true);"></td></tr>
                                            <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.dnsConfig.configure" disabled></td></tr>
                                            <tr><td>DNS&nbsp;Pass&nbsp;Host&nbsp;Domain:</td>
                                                <td><input type="checkbox" name="modify.machine.adapter${loop.index}.natEngine.dnsConfig.passHostDomain" ${adapter.natEngineSetup.dnsPassHostDomain ? "checked" : ""} disabled></td></tr>
                                            <tr><td>DNS&nbsp;Proxy:</td>
                                                <td><input type="checkbox" name="modify.machine.adapter${loop.index}.natEngine.dnsConfig.dnsProxy" ${adapter.natEngineSetup.dnsProxy ? "checked" : ""} disabled></td></tr>
                                            <tr><td>DNS&nbsp;Use&nbsp;Host&nbsp;Resolver:</td>
                                                <td><input type="checkbox" name="modify.machine.adapter${loop.index}.natEngine.dnsConfig.useHostResolver" ${adapter.natEngineSetup.dnsUseHostResolver ? "checked" : ""} disabled></td></tr>

                                            <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.aliasMode.configure" disabled></td></tr>
                                            <tr><td>Alias&nbsp;Mode:</td>
                                                <td><input type="text" name="modify.machine.adapter${loop.index}.natEngine.aliasMode" value="${adapter.natEngineSetup.aliasMode}" disabled>
                                                    <input id="modify.machine.adapter${loop.index}.natEngine.aliasMode.button" type="submit" value="Modify" onclick="return changeNATConfiguration('4', 'modify.machine.adapter${loop.index}.natEngine.aliasMode', true);"></td></tr>
                                            <tr><td><table id="natEngineForwardingRulesTable${loop.index}" class="resourceDataTable">
                                                <tr><td><input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.numberOfRules" value="${jstlfn:length(adapter.natEngineSetup.newForwardingRules)}"></td></tr>
                                                <tr><td><input type="hidden" id="modify.machine.adapter${loop.index}.natEngine.numberOfNewRules" name="modify.machine.adapter${loop.index}.natEngine.numberOfNewRules" value="0"></td></tr>
                                                <tr><td>Rule Name</td><td>Protocol</td><td>Host IP</td><td>Host Port</td><td>Guest IP</td><td>Guest Port</td><td>Remove?</td></tr>
                                                <jstlc:forEach varStatus="ruleLoop" var="rule" items="${adapter.natEngineSetup.newForwardingRules}">
                                                    <input type="hidden" name="modify.machine.adapter${loop.index}.natEngine.rule${ruleLoop.index}.name" value="${rule.name}">
                                                    <tr><td>${rule.name}</td><td>${rule.protocol}</td><td>${rule.hostIP}</td><td>${rule.hostPort}</td>
                                                        <td>${rule.guestIP}</td><td>${rule.guestPort}</td>
                                                        <td><input type="checkbox" name="modify.machine.adapter${loop.index}.natEngine.rule${ruleLoop.index}.remove"></td></tr>
                                                </jstlc:forEach>
                                                <tr id="forwardingRuleTemplateRow" class="templateElement"><td><input type="text" name=""></td><td><select  name="">
                                                            <option value="<%= NATProtocol.TCP %>">TCP</option>
                                                            <option value="<%= NATProtocol.UDP %>">UDP</option>
                                                        </select></td><td><input type="text" name=""></td><td><input type="text" size="5" name=""></td><td><input type="text" name=""></td><td><input type="text" size="5" name=""></td><td></td></tr>
                                                <tr><td><a class="actionLink" href="noJavaScript.jsp" onclick="return addPortForwardingRuleForm('natEngineForwardingRulesTable${loop.index}', 'modify.machine.adapter${loop.index}.natEngine')">Add New Rule</a></td>
                                                    <td><a class="saveButtons" href="noJavaScript.jsp" onclick="return changePopupVisibility('natEngineForwardingRulesTable${loop.index}', 'true');">Done</a></td></tr></table>
                                                </td></tr>
                                            <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return changePopupVisibility('natEngineSettingsTable${loop.index}', 'true');">Done</a></td></tr>
                                        </table>
                                        </td></tr>
                                    </jstlc:if>
                                    <tr><td><a class="saveButtons" href="noJavaScript.jsp" onclick="return saveMachineConfigurationSettings('modifyMachineNetworkAdapter${loop.index}', 'modify.machine.adapter${loop.index}', true);">Save</a></td></tr>
                                </table></td></tr>
                    </jstlc:forEach>
                    <tr><td><input type="submit" value="Update"></td></tr>
                </table>
                </form>
                </jstlc:if>
                    
                <form id="formManageStorage" action="manage_machine.jsp?action=6&amp;id=${machine.machineData.resourceId}" method="post">
                <table class="resourceDataTable" id="storageSettingsTable">
                <tr><td>Storage Controllers:</td><td><a class="${linkClass}" href="noJavaScript.jsp" onclick="return changePopupVisibility('storageControllersSettingsTable', true);">Configure</a></td></tr>
                <tr><td><table id="storageControllersSettingsTable" class="resourceDataTable">
                        <tr><td><input type="hidden" name="modify.storage.controllers.number" value="${jstlfn:length(machine.storageSettings.controllers)}"></td></tr>
                        <tr><td><input type="hidden" id="modify.storage.controllers.newNumber" name="modify.storage.controllers.newNumber" value="0"></td></tr>
                        <tr><td>Name</td><td>Connection&nbsp;Type</td><td>Controller&nbsp;Type</td><td>Host&nbsp;I/O&nbsp;Cache</td><td>Remove?</td></tr>
                        <jstlc:forEach varStatus="loop" var="controller" items="${machine.storageSettings.controllers}">
                        <tr><td><input type="hidden" name="modify.storage.controller${loop.index}.name" value="${controller.controllerName}"></td></tr>
                        <tr><td><input type="hidden" name="modify.storage.controller${loop.index}.highPort" value="${controller.highPort}"></td></tr>
                        <tr><td><input type="hidden" name="modify.storage.controller${loop.index}.highSlot" value="${controller.maxDevicesPerPort}"></td></tr>
                        <tr><td>${controller.controllerName}</td><td>${controller.connectionType}</td>
                            <td>${controller.controllerType}</td><td>${controller.hostIOCacheUsed ? "Used" : "Not Used"}</td>
                            <td><input type="checkbox" name="modify.storage.controller${loop.index}.remove"></td></tr>
                        </jstlc:forEach>
                        <tr id="controllerTemplateRow" class="templateElement"><td><input type="text" name=""></td><td><select name="">
                                    <option value="<%= StorageBus.NULL %>"><%= StorageBus.NULL %></option>
                                    <option value="<%= StorageBus.FLOPPY %>"><%= StorageBus.FLOPPY %></option>
                                    <option value="<%= StorageBus.IDE %>"><%= StorageBus.IDE %></option>
                                    <option value="<%= StorageBus.SAS %>"><%= StorageBus.SAS %></option>
                                    <option value="<%= StorageBus.SATA %>"><%= StorageBus.SATA %></option>
                                    <option value="<%= StorageBus.SCSI %>"><%= StorageBus.SCSI %></option>
                                </select></td><td><select name="">
                                    <option value="<%= StorageControllerType.NULL %>">none</option>
                                    <option value="<%= StorageControllerType.BUS_LOGIC %>">BusLogic</option>
                                    <option value="<%= StorageControllerType.ICH_6 %>">ICH6</option>
                                    <option value="<%= StorageControllerType.INTEL_AHCI %>">Intel AHCI</option>
                                    <option value="<%= StorageControllerType.I_82078 %>">I82078</option>
                                    <option value="<%= StorageControllerType.LSI_LOGIC %>">LsiLogic</option>
                                    <option value="<%= StorageControllerType.LSI_LOGIC_SAS %>">LsiLogic SAS</option>
                                    <option value="<%= StorageControllerType.PIIX_3 %>">PIIX3</option>
                                    <option value="<%= StorageControllerType.PIIX_4 %>">PIIX4</option>
                                </select></td><td><input type="checkbox" name=""></td><td></td></tr>
                        <tr><td><a class="${linkClass}" href="noJavaScript.jsp" onclick="return addControllerForm('storageControllersSettingsTable', 'modify.storage.controllers');">Add New Controller</a></td>
                            <td><a class="saveButtons" href="noJavaScript.jsp" onclick="return changePopupVisibility('storageControllersSettingsTable', 'true');">Done</a></td></tr></table></td></tr>
                <tr><td>Media Attachments:</td><td><a class="actionLink" href="noJavaScript.jsp" onclick="return changePopupVisibility('mediaAttachmentsTable', true);">Configure</a></td></tr>
                <tr><td><table id="mediaAttachmentsTable" class="resourceDataTable">
                            <tr><td><input type="hidden" name="modify.storage.attachments.number" value="${jstlfn:length(machine.storageSettings.mediumAttachments)}"></td></tr>
                            <tr><td><input type="hidden" id="modify.storage.attachments.newNumber" name="modify.storage.attachments.newNumber" value="0"></td></tr>
                            <tr><td>Medium&nbsp;UUID</td><td>Controller&nbsp;Name</td><td>Controller&nbsp;Port</td><td>Controller&nbsp;Slot</td><td>Device&nbsp;Type</td><td>Pass-Through</td><td>Detach?</td><td></td></tr>
                            <jstlc:forEach varStatus="loop" var="attachment" items="${machine.storageSettings.mediumAttachments}">
                            <tr><td>${attachment.mediumId}</td>
                                <td><input type="text" name="modify.storage.attachment${loop.index}.controllerName" value="${attachment.controllerName}" readonly></td>
                                <td><input type="text" size="2" name="modify.storage.attachment${loop.index}.controllerPort" value="${attachment.controllerPort}" readonly></td>
                                <td><input type="text" size="2" name="modify.storage.attachment${loop.index}.controllerSlot" value="${attachment.controllerSlot}" readonly></td>
                                <td><input type="text" size="9" name="modify.storage.attachment${loop.index}.deviceType" value="${attachment.deviceType}" readonly></td>
                                <td>${attachment.passthroughEnabled ? "Enabled" : "Disabled"}</td>
                                <td><input type="checkbox" name="modify.storage.attachment${loop.index}.detach"></td>
                                <td><jstlc:if test="${attachment.deviceType == DeviceType_DVD || attachment.deviceType == DeviceType_FLOPPY}">
                                        <jstlc:choose>
                                            <jstlc:when test="${attachment.mediumId != null}">
                                                <a class="actionLink"
                                                   href="manage_machine.jsp?action=7&amp;id=${machine.machineData.resourceId}&amp;controllerPort=${attachment.controllerPort}&amp;controllerSlot=${attachment.controllerSlot}&amp;controllerName=${attachment.controllerName}&amp;force">Unmount</a>
                                            </jstlc:when>

                                            <jstlc:otherwise>
                                                <a class="actionLink" href="noJavaScript.jsp"
                                                   onclick="return openMountMediumPopup('formMountMedium', '${attachment.controllerName}', '${attachment.controllerPort}', '${attachment.controllerSlot}', '${attachment.deviceType == DeviceType_DVD ? "2" : "3"}');">Mount</a>
                                            </jstlc:otherwise>
                                        </jstlc:choose>

                                    </jstlc:if></td>
                            </tr>
                            </jstlc:forEach>
                            <tr id="attachmentTemplateRow" class="templateElement"><td><input type="text" size="36" name=""></td><td><select name="" onchange="setControllerPorts(this);">
                                        <option value="0" disabled>Select Controller</option></select></td><td><select name=""><option disabled>-</option></select></td><td><select name=""><option disabled>-</option></select></td><td><select name="">
                                        <option value="<%= DeviceType.NULL %>">none</option>
                                        <option value="<%= DeviceType.HARD_DISK %>">Hard Disk</option>
                                        <option value="<%= DeviceType.DVD %>">DVD</option>
                                        <option value="<%= DeviceType.FLOPPY %>">Floppy</option>
                                    </select></td><td></td><td></td><td></td></tr>
                            <tr><td><a class="${linkClass}" href="noJavaScript.jsp" onclick="return addAttachmentForm('mediaAttachmentsTable', 'modify.storage.attachments');">Add New Attachment</a></td>
                            <td><a class="saveButtons" href="noJavaScript.jsp" onclick="return changePopupVisibility('mediaAttachmentsTable', 'true');">Done</a></td></tr></table></td></tr>
                <tr><td><table id="newMediumAttachmentElement" class="templateElement">
                            <tr><td><input type="hidden" name="" value="1"></td></tr>
                            <tr><td>Medium Format:</td><td><select name=""><option value="0" selected disabled>Select</option>
                            <jstlc:choose>
                                <jstlc:when test="${mediumFormatsData != null && mediumFormatsData.requestResult}">
                                <jstlc:forEach var="mediumFormat" items="${mediumFormatsData.resource.mediumFormats}">
                                    <option value="${mediumFormat.formatId}">${mediumFormat.formatName}</option>
                                </jstlc:forEach>
                                </jstlc:when>
                                <jstlc:otherwise>
                                <option value="0">N/A</option>
                                </jstlc:otherwise>
                            </jstlc:choose>
                            </select></td></tr>
                            <tr><td>Medium Name:</td><td><input type="text" name=""></td></tr>
                            <tr><td>Medium Variant:</td><td><select name="">
                                <option value="<%= MediumVariant.STANDARD %>">Standard</option>
                                <option value="<%= MediumVariant.DIFF %>">Differencing</option>
                                <option value="<%= MediumVariant.FIXED %>">Fixed</option>
                                <option value="<%= MediumVariant.VMDK_ESX %>"><%= MediumVariant.VMDK_ESX %></option>
                                <option value="<%= MediumVariant.VMDK_SPLIT_2_G %>"><%= MediumVariant.VMDK_SPLIT_2_G %></option>
                                <option value="<%= MediumVariant.VMDK_STREAM_OPTIMIZED %>"><%= MediumVariant.VMDK_STREAM_OPTIMIZED %></option>
                            </select></td></tr>
                            <tr><td>Permissions:</td><td><input type="text" size="2" name=""></td></tr>
                            <tr><td>Medium Size:</td><td><input type="text" size="3" name=""> MB</td></tr>
                            <tr><td>Parent UUID:</td><td><input type="text" size="36" name="" disabled></td></tr>
                        </table></td></tr>
                <tr><td><input type="submit" value="Update Storage" ${(machine.machineState == MachineState_ABORTED || machine.machineState == MachineState_POWERED_OFF) ? "" : "disabled"}></td></tr>
                </table>
                </form>
                <form id="formMountMedium" class="resourceModification" action="manage_machine.jsp?action=7&amp;id=${machine.machineData.resourceId}" method="post">
                    <input type="hidden" name="controllerSlot">
                    <input type="hidden" name="controllerPort">
                    <input type="hidden" name="controllerName">
                    Medium ID: <input type="text" size="36" name="mediumId">&nbsp;<a class="actionLink" id="mountMediumSelectionLink" href="noJavaScript.jsp" onclick="">Select</a><br>
                    Force: <input type="checkbox" name="force"><br>
                    <input type="submit" value="Mount">
                </form>
            </jstlc:when>

            <jstlc:when test="<%= data.getResourceRequestType() == ResourceRequestType.MULTIPLE_RESOURCES %>">
                <table id="machinesTable" class="resourcesTable">
                    <tr><td>UUID</td><td>Name</td><td>State</td><td>Server ID</td><td>Owner ID</td><td>OS Type</td><td></td><td></td><td>Operations</td></tr>
                <jstlc:forEach var="machine" items="${data.resourcesList}">
                    <tr>
                        <td>${machine.machineData.resourceId}</td><td>${machine.machineName}</td><td>${machine.machineState}</td>
                        <td><a href="servers.jsp?id=${machine.machineData.serverId}">${machine.machineData.serverId}</a></td>
                        <td><a href="users.jsp?id=${machine.machineData.ownerId}">${machine.machineData.ownerId}</a></td>
                        <td>${machine.osTypeId}</td><td><a class="operationsLink" href="machines.jsp?id=${machine.machineData.resourceId}">View</a></td>
                        <td><a class="operationsLink" href="manage_machine.jsp?action=8&amp;id=${machine.machineData.resourceId}"
                               onclick="return resourceRemovalVerification('${machine.machineName}', this);">Remove</a></td>
                        <td><p:printMachineOps machine="${machine}"/></td>
                    </tr>
                </jstlc:forEach>
                </table>
                <script type="text/javascript">
                    var machinesPagination = new ElementsTablePagination('machinesTable', 'machinesPagination');
                </script>
                Page Size: <input type="text" size="2" id="itemsPerPage" value="20">
                <a class="pageSizeUpdateLink" href="noJavaScript.jsp"
                   onclick="return machinesPagination.setMaxNumberOfItemsPerPage(document.getElementById('itemsPerPage').value);">Update</a>
                <div class="creationOperations">
                    <a class="creationLink" href="create_machine.jsp">Create Machine</a>
                </div>
            </jstlc:when>

            <jstlc:otherwise>
                Invalid resource request type: ${data.resourceRequestType}.
            </jstlc:otherwise>
        </jstlc:choose>
    </jstlc:when>

    <jstlc:otherwise>
        Error: ${data.exception != null ? data.exception.exceptionMessage : "Invalid data was supplied by the system."}
    </jstlc:otherwise>
</jstlc:choose>
<%-- End of Page Body Content --%>